<?php
namespace App\Http\Controllers\Rating;

use App\Http\Controllers\Controller;
use App\Common\Utils\JsonResponse;
use Illuminate\Http\Request; 

class JobController extends Controller{

    private $Request;
    private $jobService;
    private $logService;
  
    public function __construct(Request $Request)
    {
        parent::__construct();
      
        /** @var \App\Services\Rating\JobService $jobService */
        $this->jobService = app('jobService');
        $this->Request = $Request;
        /** @var \App\Services\System\LogService $logService */
        $this->logService = app('logService');
    }

    /**
     * 列表
     * @author lxy
     * @datetime 2023-03-08
     */
    public function getJobList()
    {
        try{
            $result = $this->jobService->getJobList($this->Request->all());
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /**
     * 添加
     * @author lxy
     * @datetime 2023-03-08
     */
    public function addJob()
    {
        try{
            $result = $this->jobService->addJob($this->Request->all());
            if(!empty($this->Request->all()['id'])){
                $this->logService->log('202','岗位竞聘编辑', "岗位竞聘编辑");
            }else{
                if($this->Request->all()['status'] ==1){
                    $this->logService->log('197','岗位竞聘提交', "岗位竞聘提交");
                }else{
                    $this->logService->log('197','岗位竞聘保存', "岗位竞聘保存");
                }               
            } 
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /**
     * 获取一条数据
     * @author lxy
     * @datetime 2023-03-09
     */
    public function getJobFirst()
    {
        try{
            $result = $this->jobService->getJobFirst($this->Request->all());
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /**
     * 删除
     * @author lxy
     * @datetime 2023-03-09
     */
    public function delJob()
    {
        try{
            $result = $this->jobService->delJob($this->Request->all());
            $this->logService->log('200','岗位竞聘删除', "岗位竞聘删除");
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /**
     * 选择量表
     * @author lxy
     * @datetime 2023-03-10
     */
    public function getJobScale()
    {
        try{
            $result = $this->jobService->getJobScale($this->Request->all());
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /**
     * 获取发展性项目
     * @author lxy
     * @datetime 2023-03-10
     */
    public function getJobScaleList()
    {
        try{
            $result = $this->jobService->getJobScaleList($this->Request->all());
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /**
     * 获取基础信息
     * @author lxy
     * @datetime 2023-03-13
     */
    public function getJobApplyFirst()
    {
        try{
            $result = $this->jobService->getJobApplyFirst($this->Request->all());
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /**
     * 提交申报
     * @author lxy
     * @datetime 2023-03-15
     */
    public function addApply()
    {
        try{
            $result = $this->jobService->addApply($this->Request->all());
            if($this->Request->all()['status'] == 1){
                $this->logService->log('199','岗位竞聘申报提交', "岗位竞聘申报提交");
            }else{
                $this->logService->log('199','岗位竞聘申报保存', "岗位竞聘申报保存");              
            }         
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /**
     * 添加发展性项目
     * @author lxy
     * @datetime 2023-03-16
     */
    public function addFzxxm()
    {
        try{
            $result = $this->jobService->addFzxxm($this->Request->all());
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /**
     * 发展性项目删除
     * @author lxy
     * @datetime 2023-03-16
     */
    public function delFzxxm()
    {
        try{
            $result = $this->jobService->delFzxxm($this->Request->all());
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /**
     * 获取教师申报数据
     * @author lxy
     * @datetime 2023-03-20
     */
    public function getApplyList()
    {
        try{
            $result = $this->jobService->getApplyList($this->Request->all());
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /**
     * 考核小组成员审核提交
     * @author lxy
     * @datetime 2023-03-22
     */
    public function addJobApplyCheck()
    {
        try{
            $result = $this->jobService->addJobApplyCheck($this->Request->all());
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /**
     * 获取审核基础信息
     * @author lxy
     * @datetime 2023-03-13
     */
    public function getJobApplyCheckFirst()
    {
        try{
            $result = $this->jobService->getJobApplyCheckFirst($this->Request->all());
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /**
     * 获取发展性项目审核列表
     * @author lxy
     * @datetime 2023-03-10
     */
    public function getJobScaleCheckList()
    {
        try{
            $result = $this->jobService->getJobScaleCheckList($this->Request->all());
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /**
     * 获取最终认定申报理由
     * @author lxy
     * @datetime 2023-03-23
     */
    public function getFinalJobApplyList()
    {
        try{
            $result = $this->jobService->getFinalJobApplyList($this->Request->all());
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /**
     * 获取最终认定发展性项目
     * @author lxy
     * @datetime 2023-03-24
     */
    public function getFinatJobScaleList()
    {
        try{
            $result = $this->jobService->getFinatJobScaleList($this->Request->all());
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /**
     * 获取考核小组成员申报理由分
     * @author lxy
     * @datetime 2023-03-24
     */
    public function getJobApplyUserCheck()
    {
        try{
            $result = $this->jobService->getJobApplyUserCheck($this->Request->all());
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /**
     * 获取个人考核总分
     * @author lxy
     * @datetime 2023-03-24
     */
    public function getUserCheckScores()
    {
        try{
            $result = $this->jobService->getUserCheckScores($this->Request->all());
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /**
     * 删除
     * @author lxy
     * @datetime 2023-03-24
     */
    public function delJobApply()
    {
        try{
            $result = $this->jobService->delJobApply($this->Request->all());
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /**
     * 导出
     * @author lxy
     * @datetime 2023-03-27
     */
    public function exportJobApply()
    {
        try{
            $result = $this->jobService->exportJobApply($this->Request->all());
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }
    
    /**
     * @Description: 通过条件获取基础信息
     * @Author: kzj
     * @datetime: 2023-03-30
     */
    public function getJobCompetitionInfo()
    {
        try{
            $result = $this->jobService->getJobCompetitionInfo($this->Request->all());
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /**
     * @Description: 导出
     * @Author: lxy
     * @datetime: 2023-03-30
     */
    public function exportJob()
    {
        try{
            $result = $this->jobService->exportJob($this->Request->all());
            $this->logService->log('336','岗位竞聘导出', "岗位竞聘导出");
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }
}